import socket  # 导入 socket 模块
import time
import rospy
from std_msgs.msg import String

# 设置服务器ip地址，端口，buffer容量
HOST = '192.168.1.105'
# HOST = socket.gethostname()
PORT = 8008
BUFFER = 4096

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # 创建 socket 对象
s.connect((HOST, PORT))

# ros
# rospy.init_node('TCPtalker', anonymous=0)
# pub = rospy.Publisher('Command', String, queue_size=10)

connect = True
while connect:
    strMsg = input("请输入：")
    s.sendall(strMsg.encode('utf-8'))
    if strMsg == "p":
        connect = False
        break
s.close()